home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / mtgrap1c / mtdemo.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-29  |  19.0 KB  |  786 lines

  1. /*                                                            
  2.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  3.   ▒                                                          ▒
  4.   ▒                                                          ▒
  5.   ▒             Neuromancer's Graphics Library               ▒
  6.   ▒                     Version 1.0c                         ▒
  7.   ▒                                                          ▒
  8.   ▒   This program attempts to illustrate all the features   ▒
  9.   ▒   of the mtGraph library.                                ▒ 
  10.   ▒                                                          ▒     
  11.   ▒   A very fast hack on the animation routine and          ▒         
  12.   ▒   make sure the log.blt is in the same directory.        ▒     
  13.   ▒                                                          ▒         
  14.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  15.   ▒                                                          ▒
  16.   ▒     Project:    MTLIB01.LIB                              ▒
  17.   ▒                 MTDEMO.CPP                               ▒
  18.   ▒                                                          ▒ 
  19.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  20. */
  21. #include <iostream.h>
  22. #include <conio.h>
  23. #include <stdlib.h>
  24. #include <dos.h>
  25. #include "video.h"
  26. #include "fonts.h"
  27. #include "palette.h"
  28. #include "circle.h"
  29. #include "line.h"
  30. #include "rect.h"
  31. #include "mouse.h"
  32. #include "ellipse.h"
  33. #include "sound.h"
  34. #include "key.h"
  35. #include "bitmap.h"
  36.  
  37.  
  38. extern SPRITE_HEADER     *sprite_header;
  39. extern FONT_HEADER    *font_header;
  40. FONT    **font;
  41. int    kxcor, kycor, flag=0;
  42.  
  43. byte sprite2[] = {
  44.   /*20,20,*/
  45.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
  46.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
  47.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  48.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  49.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  50.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  51.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  52.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  53.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  54.  75, 75, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 75, 75,
  55.  75, 75, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 75, 75,
  56.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  57.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  58.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  59.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  60.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  61.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  62.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  63.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
  64.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75
  65.  
  66. };
  67.  
  68. byte sprite3[]={
  69. //20,20
  70.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
  71.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
  72.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  73.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  74.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  75.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  76.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  77.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  78.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  79.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  80.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  81.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  82.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  83.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  84.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  85.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  86.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  87.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  88.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
  89.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75
  90. };
  91.  
  92. byte sprite4[]={
  93. //20,20
  94.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
  95.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
  96.  75, 75, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  97.  75, 75, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  98.  75, 75, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  99.  75, 75, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  100.  75, 75, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  101.  75, 75, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  102.  75, 75, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  103.  75, 75, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  104.  75, 75, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  105.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 75, 75,
  106.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 75, 75,
  107.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 75, 75,
  108.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 75, 75,
  109.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 75, 75,
  110.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 75, 75,
  111.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 75, 75,
  112.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
  113.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75
  114. };
  115.  
  116.  
  117. byte sprite5[]={
  118. //20,20
  119.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
  120.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
  121.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 75, 75,
  122.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 75, 75,
  123.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 75, 75,
  124.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 75, 75,
  125.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 75, 75,
  126.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 75, 75,
  127.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 75, 75,
  128.  75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 75, 75,
  129.  75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 75, 75,
  130.  75, 75, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  131.  75, 75, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  132.  75, 75, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  133.  75, 75, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  134.  75, 75, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  135.  75, 75, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  136.  75, 75, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
  137.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
  138.  75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75
  139. };
  140.  
  141.  
  142. block page1,page2;
  143.  
  144. void Click()
  145. {
  146. /*    mtSound(200,3000);
  147.     delay(5);
  148.     mtSound(500,2000);
  149.     delay(5);
  150.     mtSound(100,3000);*/
  151.  
  152.     for(register int i = 100; i< 1500; i+=2)
  153.         sound(i);
  154.     for(register int j =1500; j>100;j-=2)
  155.         sound(j);
  156.     nosound();
  157.     
  158. }
  159.  
  160. int Show_Palette_Routine()
  161. {
  162.     byte palette[768];
  163.     byte palblack[768];
  164.  
  165.     mtClearPal(palblack);
  166.  
  167.     if ((page1 = mtAllocPage(0,0,319,199))==NULL)
  168.     {
  169.         return 1;
  170.     }
  171.     
  172.     mtSetPage(PAGE_1);
  173.     if (mtLoadPCX("poolball.dat")==0)
  174.     {
  175.         return 1;
  176.     }
  177.  
  178.     mtGetAllPal(palette);
  179.     mtSetPal(palblack,0,255);
  180.     mtFlipPage(PAGE_1);
  181.  
  182.     mtFadeIn(palette,1,40);
  183.  
  184.     getch();
  185.  
  186.     mtFadeOut(30);
  187.  
  188.     mtSetPage(PAGE_0);
  189.  
  190.     mtClrScr(0);
  191.  
  192.     mtSetPage(PAGE_1);
  193.     mtLoadPCX("pacman.dat");
  194.     mtFlipPage(PAGE_1);
  195.  
  196.     return 0;
  197.  
  198. }
  199.  
  200. void Pixel_Routine()
  201. {
  202.     randomize();
  203.  
  204.     mtSetWindow(15,15,304,184);    //set up clip region
  205.  
  206.     while(!kbhit())
  207.     {
  208.        mtCPutPixel( random(320),random(200),random(256));
  209.     }
  210.     
  211. }
  212.  
  213.  
  214. void Line_Routine()
  215. {
  216.     while(!kbhit())
  217.     {
  218.        mtCLine( random(320),random(200),random(320), random(200), random(256));
  219.     }
  220. }
  221.  
  222. void Circle_Routine()
  223. {
  224.  
  225.     int x,y,major,color;
  226.  
  227.     randomize();
  228.  
  229.     while(!kbhit())
  230.     {
  231.         x = random(320)+1;
  232.         y = random(200)+1;
  233.         major = random(40);
  234.         color = random(256);
  235.  
  236.         if ((major < x ) || (major < y))
  237.         {
  238.         mtCCircle(x,y,major,color);
  239.         }
  240.      }
  241.  
  242.      getch();
  243.  
  244.      while(!kbhit())
  245.      {
  246.         x = random(320)+1;
  247.         y = random(200)+1;
  248.         major = random(40);
  249.         color = random(256);
  250.  
  251.         if ((major < x ) || (major < y))
  252.         {
  253.         mtCFillCircle(x,y,major,color);
  254.         }
  255.      }
  256.  
  257. }
  258.  
  259. void Ellipse_Routine()
  260. {
  261.     int x,y,major,minor,color;
  262.     
  263.      while(!kbhit())
  264.      {  
  265.           x = random(320)+1;
  266.         y = random(200)+1;
  267.         major = random(40);
  268.         color = random(256);
  269.         minor = random(40);
  270.  
  271.         mtCEllipse(x,y,major,minor,color);
  272.         
  273.     }
  274.  
  275.     getch();
  276.  
  277.     while(!kbhit())
  278.     {  
  279.           x = random(320)+1;
  280.         y = random(200)+1;
  281.         major = random(40);
  282.         color = random(256);
  283.         minor = random(40);
  284.  
  285.         mtCFillEllipse(x,y,major,minor,color);
  286.         
  287.     }
  288.  
  289.  
  290. }
  291.  
  292.  
  293. void Rect_Routine()
  294. {
  295.     while(!kbhit())
  296.     {
  297.        mtCRect(random(320),random(200),random(320),random(200), random(256));
  298.     }
  299.  
  300.     getch();
  301.  
  302.     while(!kbhit())
  303.     {
  304.        mtCFillRect(random(320),random(200),random(320),random(200), random(256));
  305.     }
  306. }
  307.  
  308.  
  309. int Mouse_Routine()
  310. {
  311.     int button=-1,xm=0,ym=0;
  312.     
  313.     if (mtInitMouse()==0){
  314.         return 1;
  315.     }
  316.  
  317.     mtShowMouse();
  318.  
  319.     do
  320.     {
  321.         mtGetMousePos(&button, &xm, &ym);
  322.  
  323.     }while(button<=0);
  324.  
  325.     mtHideMouse();
  326.  
  327.     return 0;
  328.  
  329. }
  330.  
  331.  
  332. int Animation_Routine()
  333. {
  334.  
  335.     int xcor;
  336.     int ycor;
  337.  
  338.     int xcor1;
  339.     int ycor1;
  340.  
  341.     int xdir;
  342.     int ydir;
  343.  
  344.     int xdir1;
  345.     int ydir1;
  346.     int flag=0;
  347.     int inc=0;
  348.     int flag1=0,inc1=0;
  349.     int flag2;
  350.     int ch;
  351.  
  352.     SPRITE        **sprite;
  353.     byte        palette[768];
  354.  
  355.     if ((sprite=mtLoadBlit("log",palette)) == NULL)
  356.     {
  357.         return 1;
  358.     }
  359.  
  360.     xcor = random(297);
  361.     ycor = random(170);
  362.     xcor1 =random(3);
  363.     ycor1 =random(1);
  364.  
  365.     xdir = 10;
  366.     ydir = 5;
  367.     xdir1 =5;
  368.     ydir1 =5;
  369.     flag=0;
  370.     inc=0;
  371.     flag1=0;
  372.     inc1=0;
  373.     flag2=0;
  374.  
  375.     if ((page2=mtAllocPage(0,0,319,199))==NULL)
  376.     {
  377.         return 1;
  378.     }
  379.     
  380.     mtCopyPage(PAGE_1,PAGE_2);
  381.  
  382.     mtSetPage(PAGE_1);
  383.     
  384.     while(!kbhit())
  385.     {
  386.         xcor += xdir;
  387.         ycor += ydir;
  388.  
  389.         xcor1 += xdir1;
  390.         ycor1 += ydir1;
  391.  
  392.         if (xcor < 0 || xcor > 290 ) {
  393.             xdir = -xdir;
  394.             xcor += xdir;
  395.         }
  396.  
  397.         if (ycor <0|| ycor >160) {
  398.             ydir = -ydir;
  399.             ycor += ydir;
  400.         }
  401.  
  402.         if (xcor1<0||xcor1 >300) {
  403.             xdir1 = -xdir1;
  404.             xcor1 += xdir1;
  405.         }
  406.         
  407.         if (ycor1 <0 || ycor1>179) {
  408.             ydir1 = -ydir1;
  409.             ycor1 += ydir1;
  410.         }
  411.  
  412.  
  413.         if(flag1==0){
  414.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  415.             inc1++;
  416.             if (inc1 == 1) flag1 =1;
  417.         }        
  418.         else
  419.         if(flag1==1){
  420.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  421.             inc1++;
  422.             if (inc1 == 2) flag1 =2;
  423.         }        
  424.         else
  425.         if(flag1==2){
  426.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  427.             inc1++;
  428.             if (inc1 == 3) flag1 =3;
  429.         }        
  430.         else
  431.         if(flag1==3){
  432.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  433.             inc1++;
  434.             if (inc1 == 4) flag1 =4;
  435.         }        
  436.         else
  437.         if(flag1==4){
  438.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  439.             inc1++;
  440.             if (inc1 == 5) flag1 =5;
  441.         }        
  442.         else
  443.         if(flag1==5){
  444.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  445.             inc1++;
  446.             if (inc1 == 6) flag1 =6;
  447.         }        
  448.         else
  449.         if(flag1==6){
  450.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  451.             inc1++;
  452.             if (inc1 ==7) flag1 =7;
  453.         }        
  454.         else
  455.         if(flag1==7){
  456.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  457.             inc1++;
  458.             if (inc1 == 8) flag1 =8;
  459.         }        
  460.         else
  461.         if(flag1==8){
  462.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  463.             inc1++;
  464.             if (inc1 == 9) flag1 =9;
  465.         }        
  466.         else
  467.         if(flag1==9){
  468.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  469.             inc1++;
  470.             if (inc1 == 10) flag1 =10;
  471.         }        
  472.         else
  473.         if(flag1==10){
  474.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  475.             inc1++;
  476.             if (inc1 == 11) flag1 =11;
  477.         }        
  478.         else
  479.         if(flag1==11){
  480.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  481.             inc1++;
  482.             if (inc1 == 12) flag1 =12;
  483.         }        
  484.         else
  485.         if(flag1==12){
  486.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  487.             inc1++;
  488.             if (inc1 == 13) flag1 =13;
  489.         }        
  490.         else
  491.         if(flag1==13){
  492.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  493.             inc1++;
  494.             if (inc1 == 14) flag1 =14;
  495.         }        
  496.         else
  497.         if(flag1==14){
  498.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  499.             inc1++;
  500.             if (inc1 == 15) flag1 =15;
  501.         }        
  502.         else
  503.         if(flag1==15){
  504.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  505.             inc1++;
  506.             if (inc1 == 16) flag1 =16;
  507.         }        
  508.         else
  509.         if(flag1==16){
  510.             mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  511.             inc1++;
  512.             if (inc1 == 17) flag1 =17;
  513.         }        
  514.         else        
  515.         if(flag1==17){
  516.             mtCPutSprite(xcor, ycor, sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
  517.             inc1++;
  518.             if (inc1 == 18) 
  519.             {
  520.                 flag1 =0;
  521.                 inc1 =0;
  522.             }
  523.         }        
  524.         
  525.         if (flag ==0){
  526.             mtCPutSprite(xcor1, ycor1, 20, 20, sprite2);    //sprite mode
  527.             inc++;
  528.             if (inc == 1) flag = 1;
  529.         }
  530.         else
  531.         if (flag==1)
  532.         {
  533.             mtCPutSprite(xcor1, ycor1, 20, 20, sprite4);    //sprite mode
  534.             inc++;
  535.             if (inc==2) flag=2;
  536.         }
  537.         else
  538.         if (flag==2)
  539.         {
  540.             mtCPutSprite(xcor1, ycor1, 20, 20, sprite3);    //sprite mode
  541.             inc++;
  542.             if (inc==3) flag=3;
  543.         }
  544.         else
  545.         if (flag==3)
  546.         {    
  547.             mtCPutSprite(xcor1, ycor1, 20, 20, sprite5);    //sprite mode
  548.             inc++;
  549.             if (inc==4)
  550.             {
  551.              flag=0;
  552.              inc=0;
  553.             }
  554.         }
  555.         
  556.         mtWaitRetrace();
  557.         mtFlipPage(PAGE_1);
  558.         if (flag1==0) flag2 =17;
  559.         else
  560.             flag2 = flag1-1;
  561.         mtCopyBlk(xcor,ycor,xcor+(sprite[flag2]->width)-1,ycor+(sprite[flag2]->height)-1,xcor,ycor,PAGE_2,PAGE_1);
  562.         mtCopyBlk(xcor1,ycor1,xcor1+19,ycor1+19,xcor1,ycor1,PAGE_2,PAGE_1);
  563.  
  564.     }
  565.  
  566.     getch();
  567.  
  568.     mtFreeBlit(sprite);
  569.  
  570.     mtFreePage(page2);
  571.  
  572.     mtSetPage(PAGE_0);
  573.     mtClrScr(0);
  574.  
  575.     return 0;
  576.  
  577. }
  578.  
  579. extern byte key[128];
  580.  
  581. void getkey()
  582. {
  583.  
  584.      if (key[ARROW_UP]==1 && kycor>1)
  585.      {        
  586.              Click();
  587.                kycor -= 10;
  588.         if (flag < sprite_header->total)
  589.             flag += 1;
  590.         else
  591.             flag  = 0;
  592.      }
  593.      if (key[ARROW_DOWN]==1 && kycor<190)
  594.      {
  595.              Click();
  596.                kycor += 10;
  597.         if (flag > 0)
  598.             flag -= 1;
  599.         else
  600.             flag  = sprite_header->total;
  601.      }
  602.      if (key[ARROW_LEFT]==1 && kxcor >1 )
  603.      {
  604.              Click();
  605.                kxcor -= 10;
  606.         if (flag < sprite_header->total)
  607.             flag += 1;
  608.         else
  609.             flag  = 0;
  610.      }
  611.      if (key[ARROW_RIGHT]==1 && kxcor < 310)
  612.      {
  613.              Click();
  614.                kxcor += 10;
  615.         if (flag > 0)
  616.             flag -= 1;
  617.         else
  618.             flag  = sprite_header->total;        
  619.      }
  620. }
  621.  
  622. int Keyboard_Routine()
  623. {
  624.  
  625.      SPRITE    **sprite;
  626.      byte      palette[768];
  627.  
  628.  
  629.      if ((sprite=mtLoadBlit("testbmp",palette)) == NULL)
  630.      {
  631.          return 1;
  632.      }
  633.  
  634.      kxcor = 10; kycor = 10;
  635.  
  636.      mtKeyInst();
  637.      mtSetPal(palette,0,255);
  638.  
  639.   
  640.      if ((page2=mtAllocPage(0,0,319,199))==NULL)
  641.      {
  642.     mtKeyUninst();
  643.     return 1;
  644.      }
  645.  
  646.      mtSetPage(PAGE_1);
  647. //   mtLoadPCX("pacman.dat");
  648.      mtCopyPage(PAGE_1,PAGE_2);
  649.  
  650.      while(!key[KEY_ESC])
  651.      {
  652.     getkey();
  653.     mtCPutSprite(kxcor, kycor,sprite[flag]->width,sprite[flag]->height,sprite[flag]->data);
  654.  
  655.      mtFlipPage(PAGE_1);
  656.     mtCopyBlk(kxcor,kycor,kxcor+(sprite[flag]->width)-1,kycor+(sprite[flag]->height)-1,kxcor,kycor,PAGE_2,PAGE_1);         
  657.      }
  658.  
  659.      mtFreePage(page2);
  660.      mtFreeBlit(sprite);
  661.      mtKeyUninst();
  662.  
  663.      mtSetPage(PAGE_0);
  664.      mtClrScr(0);
  665.      
  666.      return 0;
  667.      
  668. }
  669.  
  670. void main(void)
  671. {
  672.     byte palette[768];
  673.  
  674.     mtSetVGAMode();            //Set up VGA Mode
  675.  
  676.     font=mtLoadFont("default.fon");
  677.  
  678.     mtClrScr(0);
  679.  
  680.     mtPrintStr(105,50,"WELCOME TO",font);
  681.     mtPrintStr(35,70,"THE MTGRAPH TOOLKIT DEMO",font);
  682.         mtPrintStr(33,170,"Press any Key to Continue",font);
  683.  
  684.     getch();
  685.  
  686.     mtClrScr(0);
  687.  
  688.     if (Show_Palette_Routine() == 1)
  689.     {
  690.         mtFreeFont(font);
  691.         mtFreePage(page1);
  692.         mtSetTextMode();
  693.         cout << "Error encountered! Exiting.."<< endl;
  694.         exit(0);
  695.     }
  696.     
  697.     mtPrintStr(33,170,"Press any Key to Continue",font);
  698.  
  699.     getch();
  700.     
  701.     mtSetPage(PAGE_0);
  702.     Pixel_Routine();
  703.  
  704.     getch();
  705.  
  706.     Line_Routine();
  707.  
  708.     getch();
  709.  
  710.     Circle_Routine();
  711.  
  712.     getch();
  713.  
  714.     Rect_Routine();
  715.  
  716.     getch();
  717.  
  718.     Ellipse_Routine();
  719.  
  720.     getch();
  721.  
  722.     mtWaitRetrace();
  723.     mtFlipPage(PAGE_1);
  724.  
  725.     getch();
  726.  
  727.     mtSetWindow(0,0,319,199);
  728. //    mtSetPage(PAGE_0);
  729. //    mtClrScr(0);
  730.  
  731.     if (Keyboard_Routine() == 1)
  732.     {
  733.         mtFreeFont(font);
  734.         mtFreePage(page1);
  735.         mtSetTextMode();
  736.         cout << "Error encountered in Keyboard Routine! Exiting.."<< endl;
  737.         exit(0);
  738.     }
  739.  
  740.     mtSetPage(PAGE_1);
  741.     mtLoadPCX("screen1.dat");
  742.  
  743.     mtWaitRetrace();
  744.     mtFlipPage(PAGE_1);
  745.  
  746.     Mouse_Routine();
  747.  
  748.     mtSetPage(PAGE_0);
  749.     mtPrintStr(30,20,"Now for some Animation Examples",font);
  750.     mtPrintStr(48,170,"Press Any Key to continue",font);
  751.  
  752.     getch();
  753.  
  754.     if(Animation_Routine()== 1)
  755.     {
  756.         mtFreeFont(font);
  757.         mtFreePage(page1);
  758.         mtSetTextMode();
  759.         cout << "Error encountered in Animation Routine! Exiting.."<< endl;
  760.         exit(0);
  761.     }
  762.  
  763.     mtClrScr(0);
  764.     mtPrintStr(70,60,"THAT'S ALL FOLKS!",font);
  765.  
  766.     getch();
  767.  
  768.     mtFreeFont(font);
  769.     mtFreePage(page1);
  770.  
  771.     mtSetTextMode();
  772.  
  773.     cout << "Thank you for using the library!" << endl;
  774.  
  775.     exit(0);
  776.  
  777. }
  778.  
  779.  
  780.             
  781.  
  782.            
  783.  
  784.            
  785.  
  786.